/*
 Copyright (C) 2009 QDSS.org
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.qdss.persist.exception.jdbc;

import java.sql.SQLException;

import org.qdss.persist.exception.JDBCException;


/**
 * Implementation of JDBCException indicating that the requested DML operation
 * resulted in a violation of a defined integrity constraint.
 * 
 * @author <a href="mailto:devezhao@126.com">FANGFANG ZHAO</a>
 * @since 0.1.0, 03/19/08
 * @version $Id: ConstraintViolationException.java 44 2009-04-17 07:25:34Z zhaofang123@gmail.com $
 */
public class ConstraintViolationException extends JDBCException {
	private static final long serialVersionUID = -6763398332806161179L;

	private String constraintName;

	public ConstraintViolationException(String message, SQLException root,
			String constraintName) {
		super(message, root);
		this.constraintName = constraintName;
	}

	public ConstraintViolationException(String message, SQLException root,
			String sql, String constraintName) {
		super(message, root, sql);
		this.constraintName = constraintName;
	}

	/**
	 * Returns the name of the violated constraint, if known.
	 * 
	 * @return The name of the violated constraint, or null if not known.
	 */
	public String getConstraintName() {
		return constraintName;
	}
}
